package part18;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;

/**
 * @author wcj
 * @Date 2021/6/3 18:28
 * @Version 1.0
 */
public class Part1815 {

    /**
     * 读取二进制文件
     *
     * @param bFile
     * @return
     * @throws IOException
     */
    public static byte[] read(File bFile) throws IOException {
        BufferedInputStream bf = new BufferedInputStream(new FileInputStream(bFile));
        try {
            byte[] bytes = new byte[bf.available()];
            bf.read(bytes);
            return bytes;
        } finally {
            bf.close();
        }
    }

    public static byte[] read(String filename) throws IOException {
        return read(new File(filename));
    }

    public static void main(String[] args) throws IOException {
        System.out.println(Arrays.toString(read("./src/part18/Part1815.java")));
    }
}
